package com.fuze.navi.controller;

import com.fuze.navi.aspect.anno.AuthAdmin;
import com.fuze.navi.common.Result;
import com.fuze.navi.domain.dto.StationDTO;
import com.fuze.navi.domain.vo.CoordinateParamVO;
import com.fuze.navi.service.NavigationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Set;

/**
 * @author sepc_
 * @date 3/16/2021 15:18
 * 导航模块相关接口
 */
@Slf4j
@RequiredArgsConstructor
@RestController
public class NavigationController {

    final NavigationService navigationService;

    @AuthAdmin
    @GetMapping("/navigate/listVoltage")
    public Result listVoltage() {
        Set<String> res = navigationService.listAllVoltage();
        /*
        ArrayList<String> result = new ArrayList<>();
        result.add("交流电35KV");
        result.add("交流电110KV");
        */
        return Result.ok(res);
    }

    @AuthAdmin
    @GetMapping("/navigate/listStation")
    public Result listStation(@Validated StationDTO stationDTO) {
        return Result.ok(navigationService.listStation(stationDTO.getVoltageLevel()));
    }
    @AuthAdmin
    @GetMapping("/navigate/listLine/{stationId}")
    public Result listLine(@PathVariable(name = "stationId") Long stationId) {
        return Result.ok(navigationService.listLine(stationId));
    }

    @AuthAdmin
    @GetMapping("/navigate/listCoordinate/{lineId:\\d+}")
    public Result listCoordinate(@PathVariable(name = "lineId") Long stationId) {
        return Result.ok(navigationService.listCoordinate(stationId));
    }

    @AuthAdmin
    @PostMapping("navigate/navigate")
    public Result navigate(@Validated CoordinateParamVO coordinateVO) {
        // 导航路径规划的实现由前端直接调用高德API
        return Result.ok();
    }


}
